package com.xh.bussiness.tiku.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.bussiness.tiku.bean.request.QuestionOptionRequest;
import com.xh.bussiness.tiku.model.QuestionOption;
import com.xh.bussiness.tiku.dao.QuestionOptionMapper;
import com.xh.bussiness.tiku.service.IQuestionOptionService;
import com.xh.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.xh.core.bean.XhPage;

import java.util.List;

/**
 * <p>
 * 试题选项表 服务实现类
 * </p>
 *
 * @author daiwei
 * @since 2019-01-14
 */
@Service
public class QuestionOptionServiceImpl extends BaseServiceImpl<QuestionOptionMapper, QuestionOption> implements IQuestionOptionService {
    @Override
    public XhPage queryQuestionOptionPage(XhPage page, QuestionOptionRequest bean) {
        QueryWrapper qw=new QueryWrapper<QuestionOption>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return (XhPage) this.dao.selectPage(page,qw);
    }

    @Override
    public List queryQuestionOption(QuestionOptionRequest bean) {
        QueryWrapper qw=new QueryWrapper<QuestionOption>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return this.dao.selectList(qw);
    }


    /**
     * 准备条件
     * @param bean
     * @param qw
     */
    private QueryWrapper prepareParams(QuestionOptionRequest bean, QueryWrapper qw) {
        if(bean.getIds()!=null&&bean.getIds().length>0){
            qw.in("id",bean.getIds());
        }
        return qw;
    }
}
